<template>
  <el-dialog
    :visible.sync="dialogVisible"
    @close="close">
    <div slot="title">审核</div>
      <el-form hide-required-asterisk
       :model="refFormData"
       label-width="80px"
       class="form-container label-row"
       :rules="rules"
       ref="refForm">
      <el-form-item prop="audit" label="审核">
         <el-radio-group v-model="refFormData.audit">
          <el-radio :label=1>通过</el-radio>
          <el-radio :label=2>不通过</el-radio>
         </el-radio-group>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="warning" @click="close()">取消</el-button>
        <el-button  class="audit-btn"  @click="submit('refForm')" :loading="loading">确定</el-button>
      </span>
  </el-dialog>
</template>
<script>
  export default {
    name:'dialogBox',
    props: {
      info : {
        type: Array,
        default: () => ([])
      }
    },
    data(){
      return {
        dialogVisible: true,
        loading: false,
        refFormData:{
          audit: 1
        },
        rules: {
          audit: [
            { required: true, message: '请选择', trigger: 'change' },
          ],
        },
      };
    },
    mounted(){
    },
     methods: {

     /**
      * @Desc 数据提交
      * */
      async submit(formName){
        this.$refs[formName].validate(async (valid) => {
          if (!valid) return;

          const params = {
            ids: this.info,
            ...this.refFormData
          }
          const { data } = await this.$api.audit.audit(params)
          const { code } = data
          if(code !== 200 ) {
             this.$message.warning('数据不合法')
          } else {
            this.$message.success('审核完成')
            this.$emit('getList')
            this.close()
          }
          this.loading = false
        })
      },

     /**
      * @Desc 关闭
      * @params {String}
      * @return {Object}
      * */
      close(){
        this.$emit('close')
      }
    },
  }
</script>

<style lang='less' scoped>
</style>
